Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable negated matcher for RSpec #796

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

coorasse
Copy link
Member

@coorasse coorasse commented Jul 6, 2022

Let's not allow to specify expect(...).not_to be_able_to(:action_a, :action_b) for multiple actions. This lead in the past to too many open issues. Here are some:

Here is a recap: Marc is allowed to eat apples but not bananas.

can :collect, 🍎 
cannot :eat, 🍎 

expect(mark).to be_able to(:collect, 🍎 )
expect(mark).not_to be_able to(:eat, 🍎 )

# this below will fail, because Mark cannot eat 🍎 
expect(mark).to be_able to([:eat, :collect], 🍎 ) 

# this below will pass, because is exactly the opposite of the one above.
expect(mark).not_to be_able to([:eat, :collect], 🍎 ) 

but a reader might say "I expect Mark to not be able to eat the 🍎 !", why is he able to? This caused quite some confusion and nasty bugs. From now on you have to split the one above into:

expect(mark).to be_able to(:collect, 🍎 ) 
expect(mark).not_to be_able to(:eat, 🍎 ) 

@coorasse coorasse force-pushed the disallow_negeted_matcher_with_multiple_subjects branch from e3d28fd to e4badf3 Compare July 6, 2022 12:36
@coorasse coorasse force-pushed the disallow_negeted_matcher_with_multiple_subjects branch from e4badf3 to 1d1c8fe Compare July 6, 2022 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant